//
//  YHTransactionLookSubTableViewCell.m
//  YHApp
//
//  Created by -- on 2021/6/29.
//

#import "HATransactionLookSubTableViewCell.h"
#import "HATransactionLookListMo.h"

@interface HATransactionLookSubTableViewCell ()

/***/
@property (nonatomic, strong) UIView *mainV;
/***/
@property (nonatomic, strong) UIView *lineV;
/***/
@property (nonatomic, strong) UILabel *titleLabel;
/***/
@property (nonatomic, strong) UILabel *moneyLabel;
/***/
@property (nonatomic, strong) UILabel *stateLabel;
/***/
@property (nonatomic, strong) UILabel *snLabel;
/***/
@property (nonatomic, strong) UILabel *numLabel;
/***/
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation HATransactionLookSubTableViewCell

-(void)setModel:(HATransactionLookListMo *)model {
    _model = model;
    
    self.titleLabel.text = _model.merchantName;
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",_model.amount];
    self.stateLabel.text = _model.state;
    self.snLabel.text = [NSString stringWithFormat:@"机具编号:%@",_model.termSn];
    self.numLabel.text = [NSString stringWithFormat:@"交易流水:%@",_model.order_sn];
    self.timeLabel.text = [NSString stringWithFormat:@"交易时间:%@",model.created_at];

    [self.contentView setNeedsLayout];

}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    self.contentView.backgroundColor = [UIColor khaBGColor];
    
    if (!_model) {
        return;
    }
    
    [self.mainV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-10);
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(32);
        make.height.mas_offset(0.6);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.height.mas_offset(14);
        make.top.mas_equalTo(9);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.height.mas_offset(14);
        make.centerY.mas_equalTo(self.moneyLabel);
        make.right.mas_equalTo(self.moneyLabel.mas_left);
    }];
    
    [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.height.mas_offset(14);
        make.top.mas_equalTo(self.lineV.mas_bottom).offset(15);
    }];
    
    [self.snLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(self.stateLabel.mas_left).offset(5);
        make.top.mas_equalTo(self.lineV.mas_bottom).offset(8);
    }];

    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(self.stateLabel.mas_left).offset(5);
        make.top.mas_equalTo(self.snLabel.mas_bottom).offset(6);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(self.stateLabel.mas_left).offset(5);
        make.top.mas_equalTo(self.numLabel.mas_bottom).offset(6);
    }];

    
}

- (UIView *)mainV
{
    if (!_mainV) {
        _mainV = [UIView ha_createView];
        _mainV.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_mainV];
    }
    return _mainV;
}

- (UIView *)lineV
{
    if (!_lineV) {
        _lineV = [UIView ha_createView];
        _lineV.backgroundColor = [UIColor kLineColor];
        [self.mainV addSubview:_lineV];
    }
    return _lineV;
}

- (UILabel *)moneyLabel
{
    if (!_moneyLabel) {
        _moneyLabel = [UILabel ha_NLabelWithFont:13 textColor:@"#000000" text:@"" alignment:2];
        [self.mainV addSubview:_moneyLabel];
    }
    return _moneyLabel;
}

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel ha_NLabelWithFont:15 textColor:@"#000000" text:@"" alignment:0];
        [self.mainV addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UILabel *)stateLabel
{
    if (!_stateLabel) {
        _stateLabel = [UILabel  ha_NLabelWithFont:13 textColor:@"#0AE083" text:@"" alignment:2];
        [self.mainV addSubview:_stateLabel];
    }
    return _stateLabel;
}



- (UILabel *)snLabel
{
    if (!_snLabel) {
        _snLabel = [UILabel ha_NLabelWithFont:13 textColor:@"#858B9C" text:@"" alignment:0];
        [self.mainV addSubview:_snLabel];
    }
    return _snLabel;
}


- (UILabel *)numLabel
{
    if (!_numLabel) {
        _numLabel = [UILabel ha_NLabelWithFont:13 textColor:@"#858B9C" text:@"" alignment:0];
        [self.mainV addSubview:_numLabel];
    }
    return _numLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = [UILabel ha_NLabelWithFont:13 textColor:@"#858B9C" text:@"" alignment:0];
        [self.mainV addSubview:_timeLabel];
    }
    return _timeLabel;
}


@end
